fix: use build_agent_messages for TRL prompt + fix 4x over-generation#247
Merged
Conversation
Two critical fixes:
1. Garbage output root cause: TRL constructed user messages differently
from the standalone trainer. Standalone wraps instruction with
"Goal:" prefix, format guidance, and {"type": "image"} placeholder.
TRL passed raw instruction text. Now imports build_agent_messages
from standalone.prompt so both paths produce identical messages.
2. 4x over-generation: batch_size=num_gen with padded dataset caused
4 identical prompts × 4 generations = 16 rollouts (standalone does 4).
Now: batch_size=1, generation_batch_size=num_gen. One unique prompt
per step with num_gen rollouts. No dataset padding needed.
Also adds one-time prompt logging for operator verification.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two critical fixes for the client's ongoing TRL testing:
1. Garbage output persists after #236
The system prompt was fixed (#236) but the user message construction was still different. The standalone trainer wraps the instruction with:
Goal:prefix{"type": "image"}placeholder (Qwen's expected format)The TRL path was passing just the raw instruction string. Now imports and uses
build_agent_messages()from the standalone trainer so both paths produce identical messages.Also adds a one-time log of the first 300 chars of the rendered prompt so operators can verify the correct format.
2. 4x over-generation
per_device_train_batch_size=num_genwith dataset padding caused 4 identical prompts × 4 generations = 16 rollouts per step. The standalone trainer does 4.Fix:
per_device_train_batch_size=1,generation_batch_size=num_gen. One unique prompt per step,num_genrollouts. No dataset padding. Matches standalone behavior exactly.Test plan
🤖 Generated with Claude Code